package com.coolw.data.migrate.common.alarm;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
 * 告警状态枚举定义
 *
 * @author coolw
 * @date 2024/2/21 14:17
 */
@Getter
@AllArgsConstructor
public enum AlarmStatusEnum {

    NO_NEED_ALARM("00", "无需告警"),
    NEED_ALARM("10", "需要告警"),
    ALREADY_ALARM("20", "已告警"),
    ALARM_FAIL("30", "告警失败");

    private final String code;
    private final String desc;

    public static List<String> needAlarmStatus() {
        return Arrays.asList(NEED_ALARM.getCode(), ALARM_FAIL.getCode());
    }

    public static String getDesc(String code) {
        return Arrays.stream(values())
                .filter(r -> Objects.equals(r.getCode(), code))
                .findFirst()
                .map(AlarmStatusEnum::getDesc)
                .orElse(null);
    }
}
